<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>foreach函数</title>
</head>
<body>
兴趣爱好:
<input type="checkbox" name="interest" value="piano" />弹琴
<input type="checkbox" name="interest" value="chess"/>下棋
<input type="checkbox" name="interest" value="read"/>阅读
<input type="checkbox" name="interest" value="draw"/>画画<br/>
<input id="btn" type="button" value="遍历显示checkbox的值"/>
<br/>
<select id="s">
    <option value="taiyuan">太原</option>
    <option value="yuncheng">运城</option>
</select>
<script>
    $(function (){
        $("#btn").click(function (){
            /*:checkbox:checked表示获取被选中的复选框*/
            $(":checkbox:checked").each(function (i,n){
                let val = $(n).val();
                alert(val)
            })
        })

        $("#s").change(function (){
            let val1 = $("#s").val();
            console.log(val1)
        })
    })
</script>
</body>
</html>